<template>
    <div>
        <div class="add" v-if="(rightValue & 1) > 0" @click="add">新增</div>
        <page-list :url="url" :params="filter" @initList="_initList" ref="pageList">
            <van-cell class="card" @click="openDetail(item)" v-for="(item, index) in list" :key="index">
                <div>
                    <div>
                        <div class="title">
                            <div>{{ item.PurposeInterview }}</div>
                        </div>
                        <van-row gutter="20">
                            <van-col>
                                <img class="icon" src="@/assets/Images/AppIcon/icon_list_date.png" />约谈时间：{{ item.InterviewTime | formatDate }}
                            </van-col>
                        </van-row>
                        <van-row gutter="20">
                            <van-col>
                                <img class="icon" src="@/assets/Images/AppIcon/icon_list_area.png" />约谈地点：{{ item.PlaceInterview }}
                            </van-col>
                        </van-row>
                        <van-row gutter="20">
                            <van-col>
                                <img class="icon" src="@/assets/Images/AppIcon/icon_list_user.png" />约谈人员：{{ item.InterviewerPeople }}
                            </van-col>
                        </van-row>
                        <van-row gutter="20">
                            <van-col>
                                <img class="icon" src="@/assets/Images/AppIcon/icon_list_user.png" />记录人：{{ item.NoteTaker }}
                            </van-col>
                        </van-row>
                        <van-row gutter="20">
                            <van-col>
                                <img class="icon" src="@/assets/Images/AppIcon/icon_list_date.png" />录入时间：{{ item.CreateDate | formatDate }}
                            </van-col>
                        </van-row>
                        <van-row v-if="rightValue > 0">
                            <van-col span="24">
                                <div class="dep_btm">
                                    <div class="btm_item" v-if="(rightValue & 1) > 0" @click.stop="openEdit(item.ID)">
                                        <img src="@/assets/Images/AppIcon/icon_list_edit.png" alt="" />
                                        <div class="mr-10">编辑</div>
                                    </div>
                                    <div class="btm_item" @click.stop="delData(item)" v-if="(rightValue & 2) > 0" style="margin-right: 15px">
                                        <img src="@/assets/Images/AppIcon/icon_delete.png" alt="" />
                                        <div>删除</div>
                                    </div>
                                </div>
                            </van-col>
                        </van-row>
                    </div>
                </div>
            </van-cell>
        </page-list>
    </div>
</template>

<script>
import PageList from "../../../components/PageList/PageList.vue";
import { getMenuByMenuCode } from "@/api/common";

export default {
    components: { PageList },
    data() {
        return {
            rightValue: 0,
            url: this.$constUrl.GX_InterviewRecord_GetPageData,
            list: [],
            filter: {
                dataType: "List",
            },
        };
    },
    created() {
        this.getMenuByMenuCode();
    },
    methods: {
        _initList(list) {
            this.list = list;
        },
        openDetail(item) {
            this.$router.push({
                path: "/GxInterviewRecordView",
                query: { id: item.ID },
            });
        },
        add() {
            this.$router.push({ path: "/GxInterviewRecordEdit" });
        },
        openEdit(id) {
            this.$router.push({
                path: "/GxInterviewRecordEdit",
                query: { id: id },
            });
            return true;
        },
        delData(item) {
            this.$dialog
                .confirm({
                    title: "询问",
                    message: "您确定要删除该约谈记录吗？",
                })
                .then(() => {
                    let params = { id: item.ID };
                    this.$axios
                        .get(this.$constUrl.GX_InterviewRecord_Delete, {
                            params: params,
                        })
                        .then((res) => {
                            this.$toast("删除成功");
                            this.$refs.pageList.refreshList();
                        });
                });
        },
        getMenuByMenuCode() {
            var me = this;
            getMenuByMenuCode("GxInterviewRecord_List").then((res) => {
                me.rightValue = res.data ? res.data.RoleRightValue : 0;
            });
        },
    },
};
</script>
<style lang="less" scoped>
.dep_btm {
    display: flex;
    justify-content: flex-end;
    line-height: 27px;
    .btm_item {
        display: flex;
        align-items: center;
        img {
            height: 15px;
            width: 15px;
            margin-right: 5px;
        }
    }
}
</style>
